package com.lm.liaoming.base.custom;

import android.os.Bundle;
import android.view.View;

import com.lm.liaoming.base.IToaster;
import com.lm.liaoming.base.IUserState;
import com.lm.liaoming.constant.ConstantValues;
import com.lm.liaoming.manager.DialogManager;
import com.lm.liaoming.tool.Toaster;
import com.tumblr.remember.Remember;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

/**
 * 韦敏敏
 */

public class CustomBaseFragment extends Fragment implements IToaster, IUserState {
    @Override
    public void showToast(String toast) {

        if (getActivity() != null) {
            if (!getActivity().isFinishing()) {
                Toaster toaster = new Toaster(getActivity().getApplicationContext(), toast);
                toaster.showLoading();
//                DialogManager.showToath(getContext(),toast);
            }
        }
    }

    /**
     * toast为资源文件
     *
     * @param resId
     */
    public void showToast(int resId) {
        if (getActivity() != null) {
            if (!getActivity().isFinishing()) {
                Toaster toaster = new Toaster(getActivity(), this.getString(resId));
                toaster.showLoading();
//                DialogManager.showToath(getContext(),resId+"");
            }
        }
    }

    @Override
    public boolean isLogined() {
        return Remember.getBoolean(ConstantValues.LOGIN_STATUS, false);
    }

    @Override
    public String getToken() {
        return Remember.getString(ConstantValues.TOKEN_VALUE, "");
    }


    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        DialogManager.dimissDialog();
    }


}
